<template>
    <div>
         <el-table ref="multipleTableRef" 
            :header-cell-style="{color:'#2A62BC'}"
            :data="tableData"   
            style="width: 100%;" 
            size="small"
            border
            stripe 
            >
            <!-- <el-table-column   type="selection" width="35" /> -->
            <el-table-column  prop="options" label="考评选项"  align="center"></el-table-column>
            <el-table-column prop="score" label="评分" align="center"></el-table-column>
            </el-table>
                <!-- 分页 -->
            <div class="pagination">
                    <el-pagination
                    :current-page="query.pageIndex"
                        :page-size="query.pageSize"
                        :page-sizes="[5, 10, 15, 20]"
                        size="small"
                        layout="total, sizes, prev, pager, next, jumper"
                        :total="pageTotal"
                        @size-change="handleSizeChange"
                        @current-change="handlePageChange"/>
                </div>
                
        </div>
    </template>
    
    <script setup lang="ts">
    import { ref, reactive } from 'vue';
    import { getOptinons } from '../../../api/evaluation' ;
         
    //分页字体
    const small = ref(true)
    // const size = ref<'default' | 'large' | 'small'>('default')
    
    //分页数据
    const query = reactive({
        pageIndex: 1,
        pageSize: 5,
    });
    //表格数据
    const tableData = ref();
    //总页数
    const pageTotal = ref(0);
    const multipleTableRef = ref()
    // 获取表格数据  分页是数据截取  后台结合一起后  直接返回分页的后的数据
    const getData = () => {
        getOptinons({pageCurrent:query.pageIndex,pageSize:query.pageSize}).then(res=>{
            console.log(res,"---res---")
            // tableData.value = res.data.
            let start  = (query.pageIndex-1)*query.pageSize;//开始位置
            let end =query.pageIndex*query.pageSize  ;//结束位置 数组的截取的时候 [start,end) suo所以不用-1
            tableData.value = res.data.slice(start,end);
            // tableData.value = res.data;
            pageTotal.value = res.data.length
        })
       
        
    };
    getData();
  
    // 分页导航
    const handleSizeChange = (val) => {
      // console.log(`${val} items per page`)
      query.pageSize = val;
      getData()
    }
    const handlePageChange = (val) => {
        query.pageIndex = val;
        console.log(val,"==")
        console.log(query.pageSize)
        getData()
    };
    



</script >
<style lang="less" scoped>
  </style>